package cn.huihuo.weibo.controller;

import cn.huihuo.weibo.module.ProdComment;
import cn.huihuo.weibo.service.ParticipationService;
import cn.jfinalbbs.common.BaseController;
import cn.jfinalbbs.common.Constants;
import cn.jfinalbbs.user.User;

/**
 * Created by zhengjunbo on 2015/10/29.
 */
public class UGCController  extends BaseController {
    public void index(){
        String ugcId = getPara();

        ProdComment prodComment = ProdComment.prodComment.findUGCByUgcId(ugcId);
        if(prodComment==null){
            redirect("/");
            return;
        }

        User user = getSessionAttr(Constants.USER_SESSION);
        setAttr("participationSize", user==null?"": ParticipationService.service.findTotalParticipation(user.getStr("id")));
        setAttr("prodComment",prodComment);
        render("huihuo/ugcPage.html");
    }
}
